package com.zrf.gulimall.ware.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.zrf.gulimall.commnon.core.to.OrderTo;
import com.zrf.gulimall.commnon.core.to.SkuHasStockVo;
import com.zrf.gulimall.commnon.core.to.mq.StockLockedTo;
import com.zrf.gulimall.common.database.utils.PageUtils;
import com.zrf.gulimall.ware.entity.WareSkuEntity;
import com.zrf.gulimall.ware.vo.WareSkuLockVo;

import java.util.List;
import java.util.Map;

/**
 * 商品库存
 *
 * @author zrf
 * @email 120662332@qq.com
 * @date 2021-01-23 17:34:49
 */
public interface WareSkuService extends IService<WareSkuEntity> {

    PageUtils queryPage(Map<String, Object> params);

    /**
     * 添加库存
     * @param wareSkuEntities 需要添加的库存信息
     */
    void addStockBySkuAndWareId(List<WareSkuEntity> wareSkuEntities);

	/**
	 * 根据skuid集合查询是否有库存
	 * @param skuIdList 商品id
	 * @return skuId-boolean
	 */
	List<SkuHasStockVo> skuHasStock(List<Long> skuIdList);

	/**
	 * 锁定库存
	 * @param vo
	 * @return
	 */
	boolean orderLockStock(WareSkuLockVo vo);

	/**
	 * 解锁库存
	 * @param to
	 */
	void unlockStock(StockLockedTo to);

	/**
	 * 解锁库存
	 * @param orderTo
	 */
	void unlockStock(OrderTo orderTo);
}

